package com.basker.pisces.auth.orm;

import java.util.Date;

import com.basker.pisces.core.meta.annotation.CodeField;
import com.basker.pisces.core.meta.annotation.DataField;
import com.basker.pisces.core.meta.annotation.DataObjectMeta;
import com.basker.pisces.core.meta.annotation.TimestampField;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 认证用户，用于系统访问控制，与具体业务系统的用户不是一个概念
 *
 * @author hangwen
 */
@Getter
@Setter
@ToString
@DataObjectMeta(tableName = "AUTH_USER", schema = "${pisces.auth.schema}")
public class AuthUser {

    @DataField(dbFieldName = "AUTH_USER_ID", pkField = true)
    private Long id;

    @CodeField
    @DataField(dbFieldName = "NAME")
    private String name;

    @DataField(dbFieldName = "DISPLAYNAME")
    private String displayName;

    @DataField(dbFieldName = "PASSWORD")
    private String password;

    @DataField(dbFieldName = "CELLPHONE", length = 11)
    private String cellPhone;

    @DataField(dbFieldName = "CT")
    private Date createTime;

    @TimestampField
    @DataField(dbFieldName = "TS")
    private Long ts;

    /**
     * 明文按UTF-8编码，经过MD5加密后，按HEX解码的密文
     *
     * @return
     */
    public String getPassword() {
        return password;
    }
}
